POV-Ray : Newsgroups : povray.general : Finite accuracy computing : Finite accuracy computing Server Time
6 Aug 2024 06:16:27 EDT (-0400)
  Finite accuracy computing  
From: Gleb
Date: 9 May 2002 10:16:45
Message: <3cda84cd@news.povray.org>
An example from the book "Chaos and Fractals
New Frontiers of Science" shows how unreliable
can be calculations with finite accuracy.

Two different implementations
of the same quadratic law used:
p=p+r*p*(1-p) and

p=(1+r)*p-r*p^2, which is mathematically the same,
but results are far from that.

This simple SDL code is to demonstrate this feature:

//--------------------------8<---------------------
  camera {
    location <0,0.5,-1> look_at 0
  }
   background{rgb 1}
   #local p0=0.01;
   #local p1=p0;
   #local p2=p0;
   #local r=3;

   #local d=0.01;
   #local i=0;

   #declare Object=union{
   #while (abs(p1-p2)<1.3)
     #local p1 = p1+r*p1*(1-p1);
     #local p2 = (1+r)*p2-r*p2*p2;
     sphere{<i/100,p1-p2,0>, d}
     #local i=i+1;
   #end
  }
  #debug concat(str(i,1,0),"\n")

  #declare Object=#object{Object
  #local vv=-(max_extent(Object)-min_extent(Object))/2;
  translate vv-min_extent(Object)
  scale 0.5/vlength(vv)
}
   #object{Object}
//--------------------------8<---------------------

Calculations start with both p1 and p2 = 0.01,
and (under Win32) stop at step 187 when the difference
between them(expected to be always 0) is more then 1.3!
What do you think about it?

Gleb


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.